package com.itheima.service.impl;

import com.itheima.anno.AutoFill;
import com.itheima.aop.OperationType;
import com.itheima.mapper.DeptMapper;
import com.itheima.pojo.Dept;
import com.itheima.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;


@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptMapper deptMapper;


    @Override
    public List<Dept> list() {
        return deptMapper.list();
    }



    @Override
    public Dept getByid(Integer id) {
        return deptMapper.getById(id);
    }


    @Override
    public void deleteById(Integer id) {
        deptMapper.deleteById(id);
    }


    @AutoFill(OperationType.INSERT)
    @Override
    public void insertDapt(Dept dept) {
        deptMapper.insertDept(dept);
    }

    @Override
    public void updateDept(Dept dept) {
//        Dept d = this.getByid(dept.getId());

        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.updateDept(dept);
    }
}
